package de.stefanocke.roo.wicket.model;

import de.stefanocke.roo.wicket.base.ComponentMetadata;

/**
 * The BeanProperty metadata, enriched with type details, and, optionally, component metadata for a wicket component
 * that should be use to render the bean property.
 * 
 * @author stoc
 *
 */
public class BeanPropertyMetadataWithDetails<C extends ComponentMetadata> extends BeanPropertyMetadata {
	private JavaTypeMetadataDetails typeDetails;
	
	private C componentMetadata;

	public BeanPropertyMetadataWithDetails(BeanPropertyMetadata other, JavaTypeMetadataDetails typeDetails) {
		super(other);
		this.typeDetails = typeDetails;
	}
	
	public BeanPropertyMetadataWithDetails(BeanPropertyMetadata other, JavaTypeMetadataDetails typeDetails,
			C componentMetadata) {
		super(other);
		this.typeDetails = typeDetails;
		this.componentMetadata = componentMetadata;
	}

	public JavaTypeMetadataDetails getTypeDetails() {
		return typeDetails;
	}
	
	public boolean isEnumType() {
		return typeDetails != null && typeDetails.isEnumType();
	}
	
	public void setComponentMetadata(C componentMetadata) {
		this.componentMetadata = componentMetadata;
	}
	
	public C getComponentMetadata() {
		return componentMetadata;
	}
	
	public boolean hasComponentMetadata(){
		return componentMetadata !=null;
	}
	
}
